#ifndef __MCSEGMENTVISUAL_H_
#define __MCSEGMENTVISUAL_H_

#include <MCGraphicsItem.h>
#include <MCLineSegment2D.h>
#include <MCGripPoint.h>

class MCSegmentVisual : public MCGraphicsItem
{
public:

    MCSegmentVisual(ICanvas *presenter, const MCLineSegment2D &segment);

    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
    QPainterPath shape() const override;

    void update(const MCPoint2D &p1, const MCPoint2D &p2);
    void update(const MCPoint2D &sp, const MCVector2 &direction, double length);
    void update(double angle);
    void update(const MCLineSegment2D &segment);
    const MCLineSegment2D &lineSegment();

    void setGripAt(IGripPoint *grip, const MCPoint2D &pos) override;
    void resetGrips() override;

protected:

    MCLineSegment2D transformed() const;

private:

    MCLineSegment2D _segment;

};

#endif // !__MCSEGMENTVISUAL_H_
